# -*- shell-script -*-

# 27device_sysfs - Hardware database scanning routines and variables for sysfs.

# This file is part of the Linux lsvpd package.

# (C) Copyright IBM Corp. 2002, 2003, 2004, 2005

# Maintained by Martin Schwenke <martins@au.ibm.com>

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
 
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
    
# $Id: 27device_sysfs,v 1.1 2006/04/11 18:38:28 emunson Exp $

[ -n "$sysfs_dir" ] || return 0

######################################################################

device_get_parent_name ()
{
    # Sets: parent_name
    parent_name=""

    local bus_type="$1"
    local bus_addr="$2"

    if [ "$bus_type" = "scsi" ] ; then
	local sysfs_device_node
	get_sysfs_device_node "$bus_type" "$bus_addr"

	case "$sysfs_device_node" in
	    */usb*/*/host*)
		parent_name="usb${sysfs_device_node#*/usb}"
		parent_name="${parent_name%%/*}"
	esac
    fi
    
    [ -n "$parent_name" ] || \
	device_get_parent_name_basic "$bus_type" "$bus_addr"
}

get_yl_device ()
{
    # Sets: yl
    yl=""

    local bus_type="$1"
    local bus_addr="$2"
    local source_node="$3"
    local node="$4"

    local adapter_yl
    device_set_adapter_yl "$source_node" "$node"
    [ -n "$adapter_yl" ] && yl="${adapter_yl%/*}/${bus_addr}"
}
